<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="" style="background-color: #fff;">
    <input type="hidden" name="row[rid]" value="{$info.id}">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('录入时间')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-date" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[date]" type="text" value="{:date('Y-m-d H:i:s')}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('录入人')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-user_name" class="form-control" name="row[user_name]" type="text" value="{$admin.username}" readonly>
            <input class="form-control" name="row[user_id]" type="hidden" value="{$admin.id}">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('类别')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select class="form-control" name="row[type]"  data-rule="required">
                <option value="">请选择类别</option>
<!--                <option value="1">报案</option>-->
                <option value="2">咨询</option>
                <option value="3">退费</option>
                <option value="4">销案退费</option>
                <option value="5">客服催办</option>
                <option value="6">投诉</option>
                <option value="7">工商投诉</option>
                <option value="8">公众号投诉</option>
                <option value="9">支付投诉</option>
<!--                <option value="10">渠道催办</option>-->
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('来电人类型')}:</label>
        <div class="col-xs-12 col-sm-8" style="top: 7px;">
            <input id="c-ld_type" name="row[ld_type]" type="radio" value="1" checked>本人
            <input id="c-ld_type1" name="row[ld_type]" type="radio" value="2">他人
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('来电人姓名')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input type="hidden" id="c-name1" value="{$info.learned_name}">
            <input id="c-name" class="form-control" name="row[name]" type="text" data-rule="required" value="{$info.learned_name}">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('来电人电话')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-phone" class="form-control" name="row[phone]" type="text" value="{$info.phone}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('车型')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select name="row[chexing]" id="c-chexing"  class="form-control" data-rule="required">
                <option value="">请选择车辆类型</option>
                <?php foreach($chexing as $k => $v){?>
                    <option value="{$v}">{$k}</option>
                <?php }?>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('备注')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-content" class="form-control" name="row[content]" type="text"></textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('查勘人')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select name="row[fenpei]" id="c-fenpei"  class="form-control">
                <option value="">请选择查勘人</option>
                {volist name="fenpei" id="vo"}
                <option value="{$vo.id}">{$vo.username}</option>
                {/volist}
            </select>
        </div>
    </div>

    <div class="form-group" style="margin-top: 50px;padding-bottom: 50px;margin-left: 150px;">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 " style="margin: auto;">
            <button type="button" class="btn btn-primary btn-embossed " style="margin-left: 10px;" onclick="zuihou_save()">{:__('保存并关闭')}</button>
        </div>
    </div>
</form>

<script src="/assets/libs/jquery/dist/jquery.js"></script>
<script>
    function zuihou_save() {
        var formData = $("#add-form").serialize();
        $.ajax({
            url: "{:url('kf/record/save_list')}",
            data: formData,
            type: 'post',
            dataType: 'json',
            success: function (ret) {
                if (ret.code == 1) {
                    var res = ret.data
                    var html = `<tr class="form-inline">
                                <td class="idd" style="display: none"><input type="hidden" name="row[id]" value="`+res.id+`"></td>
                                <td class="tt">`+res.date+`</td>
                                <td class="name">`+res.user_name+`</td>
                                <td class="type">`+res.type+`</td>
                                <td>`+res.ld_type+`</td>
                                <td>`+res.name+`</td>
                                <td>`+res.phone+`</td>
                                <td>`+res.chexing+`</td>
                                <td class="content">`+res.content+`</td>
                                <td style="width: 240px;" class="caozuo">
                                    `+res.fenpei+`
                                </td>
                                <td>

                                    <input class="save" type="button"  value="编辑" style="width:50px!important;height:30px;border: none;background:#3683D3 !important;color: #fff;" onclick="AddRow1(`+res.id+`)">
</td>
                                <td class="content"></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>`;
                    $('#first-table1', window.parent.document).append(html);
                    layer.msg('保存成功！', {
                        time: 1000,
                        icon: 1
                    }, function (index) {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //执行关闭
                    })
                } else {
                    layer.alert(ret.msg)
                }
            }
        })
    }
    $("#c-ld_type").on("click", function() {
        var name = $('#c-name1').val();
        $('#c-name').val(name)
    })
    $("#c-ld_type1").on("click", function() {
        $('#c-name').val('')
    })
</script>